import { reactive, onMounted, onBeforeMount} from "vue";

export default function savePoint(){
    interface obj{
        x:Number,
        y:Number,
    }
    let point = reactive<obj>({
        x:0,
        y:0,
    });
    //实现鼠标打点相关的方法。
    function savePoint(event:any):void{
        point.x = event.pageX;
        point.y = event.pageY;
        console.log(event, event.pageX, event.pageY);
    }

    onMounted(():void => {
        window.addEventListener("click", savePoint);
    }),
    onBeforeMount(():void=>{
        window.removeEventListener("click", savePoint);
    })

    return point;
}